Hello, |
Re: Running the same script across multiple modules for metrics Is there a way for the results to be displayed as a text file instead of just in the DXL Interaction GUI? |
Re: Running the same script across multiple modules for metrics SystemAdmin - Thu Jun 07 15:11:16 EDT 2012 You will find everything you need... |
Re: Running the same script across multiple modules for metrics
I'm not completely sure about your needs, but I think you ask for a loop over all modules in a project or a range of folders.
Item i
for i in project "myproject" do {
if "Formal" != type i then continue
Module m = read (fullName i, false, true)
…DoSomeStuff…
close (m)
}
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Thu Jun 07 16:44:49 EDT 2012
I'm not completely sure about your needs, but I think you ask for a loop over all modules in a project or a range of folders.
Item i
for i in project "myproject" do {
if "Formal" != type i then continue
Module m = read (fullName i, false, true)
…DoSomeStuff…
close (m)
}
For question #1 ... is there way to call out specific modules, so I can potentially group by the subsystem, instead of looping through the entire project? string filename = tempFileName print "Writing to " filename "\n" Stream out = write filename Buffer bufResults = create() Filter fShall = contains(attribute "Object Text", "shall") set (mod, fShall, NumShall, xShall) print "No. of 'shall' requirements: " NumShall "\n" out << bufResults close out delete bufResults
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Mon Jun 11 15:20:08 EDT 2012
For question #1 ... is there way to call out specific modules, so I can potentially group by the subsystem, instead of looping through the entire project? string filename = tempFileName print "Writing to " filename "\n" Stream out = write filename Buffer bufResults = create() Filter fShall = contains(attribute "Object Text", "shall") set (mod, fShall, NumShall, xShall) print "No. of 'shall' requirements: " NumShall "\n" out << bufResults close out delete bufResults
Again I am not sure about your needs. What is a "subsystem" in your environment? How can you tell what subsystem a module belongs to? If the subsystem is a part of the module name or of the name of a folder or sub-folder, you might want to check the "fullName" of the module (e.g. using a regular expression), before opening it. If the subsystem is an attribute of the module, you might want to check the "ModuleProperties" of it before opening it. (a. see DXL help / b. beware the |
Re: Running the same script across multiple modules for metrics SystemAdmin - Mon Jun 11 15:20:08 EDT 2012
For question #1 ... is there way to call out specific modules, so I can potentially group by the subsystem, instead of looping through the entire project? string filename = tempFileName print "Writing to " filename "\n" Stream out = write filename Buffer bufResults = create() Filter fShall = contains(attribute "Object Text", "shall") set (mod, fShall, NumShall, xShall) print "No. of 'shall' requirements: " NumShall "\n" out << bufResults close out delete bufResults
About #2: print "No. of …"
bufResults += "No. of …"
out << "No. of …"
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Mon Jun 11 17:43:07 EDT 2012
About #2: print "No. of …"
bufResults += "No. of …"
out << "No. of …"
#2 ... thanks, adding 'out >>' and deleting the buffer worked great w/ one exception. I wanted to display the date and time as well but Date d = dateAndTime(today) print d out << d
out << d
out << dataAndTime(today)
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Wed Jun 13 11:24:04 EDT 2012
#2 ... thanks, adding 'out >>' and deleting the buffer worked great w/ one exception. I wanted to display the date and time as well but Date d = dateAndTime(today) print d out << d
out << d
out << dataAndTime(today)
So, convert your date to a string (e.g. using the function stringOf) and output the result. |
Re: Running the same script across multiple modules for metrics SystemAdmin - Wed Jun 13 14:17:14 EDT 2012 |
Re: Running the same script across multiple modules for metrics SystemAdmin - Mon Jun 11 17:26:07 EDT 2012
#2 ... Thanks! ... it now shows the date in the output file :)
for i in flder do {
if (type(i) == "Formal"){
print fullName(i) "\n"
// run my req metrics script(described in Q#2)
}
}
|
Re: Running the same script across multiple modules for metrics llandale - Wed Jun 13 16:37:59 EDT 2012
#2 ... Thanks! ... it now shows the date in the output file :)
for i in flder do {
if (type(i) == "Formal"){
print fullName(i) "\n"
// run my req metrics script(described in Q#2)
}
}
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Wed Jun 13 17:11:10 EDT 2012
#2 ... Thanks! ... it now shows the date in the output file :)
for i in flder do {
if (type(i) == "Formal"){
print fullName(i) "\n"
// run my req metrics script(described in Q#2)
}
}
Tried the following, but it creates a file that just shows the code of the dxl script (over and over again for each module), instead of actually executing it :(
string filename = tempFileName
print "Writing to ... " filename "\n\n"
Stream ofile = write filename
for i in flder do {
if (type(i) == "Formal"){
print fullName(i) "\n"
// run my req metrics script(described in Q#2)
string results = readFile("C:\\.../Req Metrics.dxl") // not the actual path, deleted the details
ofile << results
}
}
close(ofile)
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Wed Jun 13 17:35:15 EDT 2012
Tried the following, but it creates a file that just shows the code of the dxl script (over and over again for each module), instead of actually executing it :(
string filename = tempFileName
print "Writing to ... " filename "\n\n"
Stream ofile = write filename
for i in flder do {
if (type(i) == "Formal"){
print fullName(i) "\n"
// run my req metrics script(described in Q#2)
string results = readFile("C:\\.../Req Metrics.dxl") // not the actual path, deleted the details
ofile << results
}
}
close(ofile)
see http://www.smartdxl.com/content/?p=444
|
Re: Running the same script across multiple modules for metrics SystemAdmin - Wed Jun 13 17:35:15 EDT 2012
Tried the following, but it creates a file that just shows the code of the dxl script (over and over again for each module), instead of actually executing it :(
string filename = tempFileName
print "Writing to ... " filename "\n\n"
Stream ofile = write filename
for i in flder do {
if (type(i) == "Formal"){
print fullName(i) "\n"
// run my req metrics script(described in Q#2)
string results = readFile("C:\\.../Req Metrics.dxl") // not the actual path, deleted the details
ofile << results
}
}
close(ofile)
You need to execute the script, not read its contents. For this you can use eval_. To redirect the output in case of print statements you would do a print redirection:
string sFileName = tempFileName() // the output file
Stream stLog = write sFileName // open the file
// pass it to the eval_ context and make print write to it
string sPrintRedirectionCode = "
Stream gPrintStream = addr_ " ((addr_ stLog) int) "
void print (Date d) { gPrintStream << d \"\\n\" ; flush gPrintStream }
void print (string s) { gPrintStream << s; flush gPrintStream }
void print (AttrBaseType ab){ gPrintStream << ab \"\\n\"; flush gPrintStream }
void print (int i) { gPrintStream << i \"\\n\" ; flush gPrintStream }
void print (char ch) { gPrintStream << ch \"\\n\" ; flush gPrintStream }
void print (HistoryType ht) { gPrintStream << ht \"\\n\" ; flush gPrintStream }
void print (bool b) { gPrintStream << b \"\\n\" ; flush gPrintStream }
void print (real r) { gPrintStream << r \"\\n\" ; flush gPrintStream }
"
// string sCode = = readFile("C:\\.../Req Metrics.dxl") // use your script for execution
string sCode = "print \"Hello World!\"" // use the script from readfile instead ...
eval_ sPrintRedirectionCode sCode
close stLog
print "Check the file " sFileName "\n"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|